package com.sakura.thread.chapter11;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by apple on 2018/12/24.
 */
public class TestShutDown {
    static void asyncExecuteOne(){
        ExecutorService executor = Executors.newSingleThreadExecutor();
        executor.execute(new Runnable() {
            @Override
            public void run() {
                System.out.println("---async execute one ---");
            }
        });

        executor.shutdown();
    }

    static void asyncExecuteTwo(){
        ExecutorService executor = Executors.newSingleThreadExecutor();
        executor.execute(new Runnable() {
            @Override
            public void run() {
                System.out.println("---async execute two ---");
            }
        });
        executor.shutdown();
    }

    public static void main(String[] args) {
        System.out.println("async ---");

        asyncExecuteOne();
        asyncExecuteTwo();

        System.out.println("over");
    }
}
